using MicroMsg.Common.Event;
using MicroMsg.Protocol;
using MicroMsg.Resource.@string;
using MicroMsg.Scene;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.Page
{
	public class RegByPhoneStepInputVCode : BasePage
	{
		private EventWatcher mWatcherPhoneReg;
		internal Grid LayoutRoot;
		internal Grid sencondRoot;
		internal panelTitle2Line panelTitle;
		internal StackPanel ContentPanel;
		internal TextBlock textBlock2;
		internal TextBlock textBlockUserPhoneNumber;
		internal TextBlock textBlock1;
		internal PhoneTextBox textBoxInputVcode;
		internal Button btnGetVoiceCode;
		private bool _contentLoaded;
		public RegByPhoneStepInputVCode()
		{
			this.InitializeComponent();
			this.SetAppBarWording();
		}
		protected override void OnPageIn(object[] object_0)
		{
			if (object_0 != null && object_0.Length != 0)
			{
				this.textBlockUserPhoneNumber.set_Text(object_0[0] as string);
				string text = "";
				if (object_0.Length > 1)
				{
					text = (object_0[1] as string);
				}
				if (text.Contains("+86 "))
				{
					this.btnGetVoiceCode.set_Visibility(1);
				}
				else
				{
					this.btnGetVoiceCode.set_Visibility(0);
				}
			}
			if (this.mWatcherPhoneReg == null)
			{
				this.mWatcherPhoneReg = new EventWatcher(this, null, new EventHandlerDelegate(this.onPhoneAuthRegHandler));
				EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_MOBILEREG_VERIFY_SUCCESS, this.mWatcherPhoneReg);
				EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_MOBILEREG_VERIFY_ERR, this.mWatcherPhoneReg);
			}
		}
		protected override void OnPageOut()
		{
			if (this.mWatcherPhoneReg != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_MOBILEREG_VERIFY_SUCCESS, this.mWatcherPhoneReg);
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_MOBILEREG_VERIFY_ERR, this.mWatcherPhoneReg);
				this.mWatcherPhoneReg = null;
			}
		}
		private void onPhoneAuthRegHandler(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			this.enableAllControls();
			if (evtArgs.mEventID == EventConst.ON_NETSCENE_MOBILEREG_VERIFY_SUCCESS)
			{
				base.GoToPage("/Source/UI/LoginViews/RegByPhoneStepSetPass.xaml", null, false);
				return;
			}
			if (evtArgs.mEventID == EventConst.ON_NETSCENE_MOBILEREG_VERIFY_ERR)
			{
				RetConst retConst = (RetConst)evtArgs.mObject;
				RetConst retConst2 = retConst;
				if (retConst2 == RetConst.MM_ERR_CLIENT)
				{
					MMMessageBox.Show("", strings.Reg_PhoneV_MsgBadNet, 1, true, strings.COM_Confirm, "取消");
					return;
				}
				MMMessageBox.Show(strings.Reg_PhoneV_MsgBadV, strings.Reg_PhoneV_MsgBadV2, 1, true, strings.COM_Confirm, "取消");
			}
		}
		private void btnGetVerifyCodeByVoice_Click(object sender, RoutedEventArgs e)
		{
			base.GoToPage("/Source/UI/LoginViews/RegByPhoneStepVoiceCode.xaml", new object[]
			{
				"reg"
			}, false);
		}
		private void btnPreviousStep_Click(object sender, EventArgs e)
		{
			base.GoBack();
		}
		private void btnNextStep_Click(object sender, EventArgs e)
		{
			this.disableAllControls();
			ServiceCenter.sceneBindOpMobileForReg.doSceneVerify(this.textBoxInputVcode.get_Text());
		}
		private void textBoxInputVcode_GotFocus(object sender, RoutedEventArgs e)
		{
		}
		private void textBoxInputVcode_TextChanged(object sender, TextChangedEventArgs e)
		{
			if (this.textBoxInputVcode.get_Text().get_Length() != 0 && ToolFunction.checkIsNumber(this.textBoxInputVcode.get_Text()))
			{
				(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(true);
				return;
			}
			(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(false);
		}
		private void enableAllControls()
		{
			ProcessingCover.releaseProgressBar(this.LayoutRoot);
			(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(true);
		}
		private void disableAllControls()
		{
			ProcessingCover.getProgressBar(this.LayoutRoot, strings.Reg_PhoneV_MsgSending, null, false, false, null);
			(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(false);
		}
		public void SetAppBarWording()
		{
			if (base.get_ApplicationBar() != null && 1 == base.get_ApplicationBar().get_Buttons().get_Count())
			{
				ApplicationBarIconButton applicationBarIconButton = (ApplicationBarIconButton)base.get_ApplicationBar().get_Buttons().get_Item(0);
				applicationBarIconButton.set_Text(strings.COM_Next);
			}
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/LoginViews/RegByPhoneStepInputVCode.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.sencondRoot = (Grid)base.FindName("sencondRoot");
			this.panelTitle = (panelTitle2Line)base.FindName("panelTitle");
			this.ContentPanel = (StackPanel)base.FindName("ContentPanel");
			this.textBlock2 = (TextBlock)base.FindName("textBlock2");
			this.textBlockUserPhoneNumber = (TextBlock)base.FindName("textBlockUserPhoneNumber");
			this.textBlock1 = (TextBlock)base.FindName("textBlock1");
			this.textBoxInputVcode = (PhoneTextBox)base.FindName("textBoxInputVcode");
			this.btnGetVoiceCode = (Button)base.FindName("btnGetVoiceCode");
		}
	}
}
